package com.aclass.xqx.classscreen.model;

import android.util.Log;

import com.aclass.xqx.classscreen.bean.GoingToBean;
import com.aclass.xqx.classscreen.db.CardDao;
import com.aclass.xqx.classscreen.db.CardStudent;
import com.aclass.xqx.classscreen.db.ClassSchedule;
import com.aclass.xqx.classscreen.db.StudentSign;
import com.aclass.xqx.classscreen.utlis.ClassCalendar;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by xqx on 2017/11/22.
 * 照片墙模型
 */
public class StudentPhotosModel {
    //返回实到人数
    public List<CardStudent> getTonum(){
        List<CardStudent> cardStudents = CardDao.queryStudent();
        List<CardStudent> students=new ArrayList<>();
        students.clear();
        long lMinuts = Long.parseLong(ClassCalendar.getStringMinuts());
        long NMinuts = Long.parseLong(ClassCalendar.getStringDays("12", "00"));
        Log.e("ATG",lMinuts+"   "+NMinuts);
        if (lMinuts<NMinuts) {
            for (CardStudent student:cardStudents){
                StudentSign studentSign = student.getStudentSign();
                if (studentSign!=null){
                    long time = Long.parseLong(studentSign.getTime());
                    String stringDays = ClassCalendar.getStringDays("06", "00");
                    if (time > Long.parseLong(stringDays)) {
                        students.add(student);
                    }
                }
            }
        }else{
            for (CardStudent student:cardStudents){
                StudentSign studentSign = student.getStudentSign();
                if (studentSign!=null){
                    long time = Long.parseLong(studentSign.getTime());
                    String stringDays = ClassCalendar.getStringDays("13", "00");
                    if (time > Long.parseLong(stringDays)) {
                        students.add(student);
                    }
                }

            }
        }
        return students;
    }
    public List<CardStudent> getonTonum(){
        List<CardStudent> cardStudents = CardDao.queryStudent();
        List<CardStudent> students=new ArrayList<>();
        students.clear();
        long lMinuts = Long.parseLong(ClassCalendar.getStringMinuts());
        long NMinuts = Long.parseLong(ClassCalendar.getStringDays("12", "00"));
        Log.e("ATG",lMinuts+"   "+NMinuts);
        if (lMinuts<NMinuts) {
            for (CardStudent student:cardStudents){
                StudentSign studentSign = student.getStudentSign();
                if (studentSign!=null){
                    long time = Long.parseLong(studentSign.getTime());
                    String stringDays = ClassCalendar.getStringDays("06", "00");
                    if (time < Long.parseLong(stringDays)) {
                        students.add(student);
                    }
                }else {
                    students.add(student);
                }
            }
        }else{
            for (CardStudent student:cardStudents){
                Log.e("ATG","学生"+cardStudents.size());
                StudentSign studentSign = student.getStudentSign();
                if (studentSign!=null){
                    long time = Long.parseLong(studentSign.getTime());
                    String stringDays = ClassCalendar.getStringDays("12", "00");
                    if (time < Long.parseLong(stringDays)) {
                        students.add(student);
                    }
                }else {
                    students.add(student);
                }

            }
        }
        return students;
    }
    public String GoingTo(){
        String strhour = ClassCalendar.getHour();
        double hour = Double.parseDouble(strhour);
        List<ClassSchedule> classSchedules = CardDao.queryscheduleWeek(ClassCalendar.getWeekDays() + "");
        for (ClassSchedule schedule:classSchedules){
            Log.e("WC",schedule.getEnd_time()+" "+schedule.getSubject_name());
            String start_time = schedule.getStart_time();
            String end_time = schedule.getEnd_time();
            String start_time1 =start_time.substring(0, 2);
            String start_time2 = start_time.substring(3);
            String end_time1 =end_time.substring(0, 2);
            String end_time2 = end_time.substring(3);
            String s = start_time1 + "." + start_time2;
            String s1 = end_time1 + "." + end_time2;
            double v = Double.parseDouble(s);
            double endTime = Double.parseDouble(s1);
            Log.e("WC","时间sss"+endTime+"  "+v+"  档"+hour);
            if (hour>v&&hour<endTime){
                Log.e("WC","当前课程"+schedule.getSubject_name()+schedule.getStart_time());
                return schedule.getSubject_name();
            }
        }
        return "暂无";
    }
}
